ntp:
  pkg:
    - installed

  service:
    {% if grains['os'] == 'CentOS' or grains['os'] == 'RedHat' %}
    - name: ntpd
    {% endif %}
    - running
    - enable: true
    - watch:
      - file: /etc/ntp.conf

  file.managed:
    {% if grains['os'] == 'Debian' or grains['os'] == 'Ubuntu' %}
    - name: /etc/ntp.conf
    - source: salt://ntp/files/ntp.conf.debian.jinja

    {% elif grains['os'] == 'CentOS' or grains['os'] == 'RedHat' %}
    - name: /etc/ntp.conf
    - source: salt://ntp/files/ntp.conf.redhat.jinja
    
    {% endif %}
    
    - mode: 644
    - template: jinja
    - defaults:
          servers: ['ntp1.aliyun.com',
                  'ntp2.aliyun.com',
                  'ntp3.aliyun.com',
                  'ntp4.aliyun.com']
    - require:
      - pkg: ntp


Asia/Shanghai:
    timezone.system:
      - utc: True
